console.log(Object.prototype.toString.call(null))
//[object Null]
console.log(Object.prototype.toString.call(123))
//[object Number]
console.log(Object.prototype.toString.call('123'))
//[object String]
console.log(Object.prototype.toString.call(undefined))
//[object Undefined]
console.log(Object.prototype.toString.call(new Date()))
//[object Date]
console.log(Object.prototype.toString.call(function(){}))
//[object Function]
console.log(Object.prototype.toString.call([]))
//[object Array]
console.log(Object.prototype.toString.call(true))
//[object Boolean]
當 typeof 變數,變數本身有宣告但並未賦值,會出現 undefined
var a ;
console.log(typeof a)
//undefined
當變數未宣告且未賦值,會出現 error
console.log(a)
ReferenceError: a is not defined
at Object.<anonymous> (/Users/rock/.bitnami/stackman/machines/xampp/volumes/root/htdocs/rock/week16-js/type.js:21:13)
at Module._compile (internal/modules/cjs/loader.js:1158:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
at Module.load (internal/modules/cjs/loader.js:1002:32)
at Function.Module._load (internal/modules/cjs/loader.js:901:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
at internal/main/run_main_module.js:18:47